-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN/TYPE: window aggregation cleanups and typing #30137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
pandas/_libs/window/aggregations.pyx
Outdated
|
||
is_monotonic_bounds = np.all(np.diff(start) > 0) and np.all(np.diff(end) > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this a cdef
function instead of copy?
@@ -412,7 +412,7 @@ def _get_roll_func(self, func_name: str) -> Callable: | |||
) | |||
return window_func | |||
|
|||
def _get_cython_func_type(self, func): | |||
def _get_cython_func_type(self, func: str) -> Callable: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible to add subtypes to Callable
typically very helpful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately the arguments to the cython functions for rolling are still not entirely uniform so the argument list can't be typed consistently.
pandas/_libs/window/aggregations.pyx
Outdated
|
||
is_monotonic_bounds = np.all(np.diff(start) > 0) and np.all(np.diff(end) > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this call expensive? we might have something in _libs.algos that short-circuits this check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. Was able to use is_monotonic
in _libs.algos
pandas/_libs/window/aggregations.pyx
Outdated
|
||
is_monotonic_bounds = np.all(np.diff(start) > 0) and np.all(np.diff(end) > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make this a function
pandas/_libs/window/aggregations.pyx
Outdated
|
||
is_monotonic_bounds = is_monotonic(start, False)[0] and is_monotonic(end, False)[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worth making this an inline helper function (not a big deal though)
All green. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
* Move is_monotonic_bounds to the aggregation functions * Remove single usage of _check_min in aggregations.pyx * remove _check_min * Add some typing * fix condition * Use is_monotonic from _lib.algos * Add inline helper function
* Move is_monotonic_bounds to the aggregation functions * Remove single usage of _check_min in aggregations.pyx * remove _check_min * Add some typing * fix condition * Use is_monotonic from _lib.algos * Add inline helper function
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff